Each track of a disk in a computer is divided into multiple arc segments, and each arc segment is a sector of the disk. An operation system may divide the disk space of the disk into multiple disk volumes to manage the disk. For example, C disk is a disk volume. The space of each disk volume is further divided into multiple clusters. A Logical Cluster Number (LCN) is a serial number of a cluster in the disk volume. LCNs may be assigned to clusters in a disk volume according to the physical locations of the clusters in the disk volume. And thus, a LCN may represent the physical location of a cluster in the disk volume. Cluster is the smallest unit of disk file storage and management. Sectors included in one cluster may be different from sectors included in another cluster because of different file systems.
In actual applications, many file fragmentations may be generated on the disk along with the usage of the computer. That is, different parts of a file may be stored in multiple clusters in a disk volume, and the LCNs of the multiple clusters may be incontinuous, as shown in FIG. 1.
FIG. 1 is a diagram illustrating file storage on a disk.
Each cell in FIG. 1 represents one cluster. As shown in FIG. 1, a file C is stored continuously, and a file A and a file B both include file fragmentations. That is, the LCNs of clusters in which the file A is stored are incontinuous, and the LCNs of clusters in which the file B is stored are also incontinuous.
Because the file fragmentations are not stored on the disk continuously, the seek time of the disk is increased, thereby decreasing the Input/Output (IO) performance of the disk.
The scattered file fragmentations may be put together again through disk defragmentation, so that all contents of a file are stored continuously on the disk. Accordingly, the IO performance of the disk may be improved. Further, when the scattered file fragmentations are put together again, the file may be compressed, thereby implementing compact arrangement.
The conventional disk defragmentation solution just integrates file fragmentations of a file together to make the file fragmentations of the file be stored continuously on the disk. However, if new contents are added into the file afterwards, new file fragmentations may be generated, which may result in repeated disk defragmentation.